function reserveSeat(seat) {
	if (!seat.reserved) {
		if (seat.marked) {
			seat.src = "/Cinema_Ticket_System/resources/images/WhiteSeat.png";
			seat.marked = false;
			var checkbox = document.getElementById(seat.id + '_c');
			checkbox.checked = false;
		} else {
			seat.src = "/Cinema_Ticket_System/resources/images/GreenSeat.png";
			seat.marked = true;
			var checkbox = document.getElementById(seat.id + '_c');
			checkbox.checked = true;
		}
	}	
};

window.onload = function() {
	var checkedCheckboxes = $("input[type=checkbox]:checked");
	for (var i = 0; i < checkedCheckboxes.size(); i++) {
	    var checkBox = checkedCheckboxes[i];
	    var seat = document.getElementById(checkBox.id.substring(0, checkBox.id.lastIndexOf("_")));
	    seat.src = "/Cinema_Ticket_System/resources/images/RedSeat.png";
	    seat.reserved = true;
	};
};